<?php


namespace app\libs\exception;


use think\Exception;
use Throwable;

class BaseException extends Exception
{
    public $code = 500;
    public $message = "对不起, 服务器内部异常(*￣︶￣)!";
    public $error_code = 999;

    /**
     * @throws ParamException
     */
    public function __construct($param = [])
    {
        if (!is_array($param)) {
            throw new ParamException();
        }

        if (array_key_exists('code', $param)) {
            $this->code = $param['code'];
        }

        if (array_key_exists('message', $param)) {
            $this->message = $param['message'];
        }

        if (array_key_exists('error_code', $param)) {
            $this->error_code = $param['error_code'];
        }
    }
}